package io.zhiller.koinbasictemplate.di.module

import io.zhiller.koinbasictemplate.di.repo.BasicRepoImpl
import io.zhiller.koinbasictemplate.di.viewmodel.BasicVM
import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.core.module.dsl.createdAtStart
import org.koin.core.module.dsl.factoryOf
import org.koin.core.module.dsl.named
import org.koin.core.module.dsl.singleOf
import org.koin.core.module.dsl.withOptions
import org.koin.dsl.module

class BasicFactory(
  private val name: String,
  private val age: Int
) {
  fun getData(): String = "$name $age"
}

class BasicSingleton {
  private val name = "Singleton"
  fun getData(): String = name
}

val basicModules = module {
  factoryOf(::BasicFactory)
  singleOf(::BasicSingleton).withOptions {
    named("basic_singleton")
    createdAtStart()
  }
}

val repoModules = module {
  single { BasicRepoImpl() }
}

val vmModules = module {
  viewModel { BasicVM(get()) }
}